package cn.cxion.chat.app.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.cxion.chat.R;
import cn.cxion.chat.app.constant.Constant;

public class SettingView {

    private Context context;
    private int classId;
    private View view;

    public SettingView(Context context, int classId) {
        view = LayoutInflater.from(context).inflate(R.layout.view_setting, null);
        this.context = context;
        this.classId = classId;
        bindView();
    }

    public View getView() {
        return view;
    }

    private void bindView() {


        ViewHolder holder = new ViewHolder(view);
        String className = Constant.getClassKeyMap().get(classId);
        String name = className.substring(2, className.length());
        if (classId == Constant.SEX) {
            holder.etName.setVisibility(View.GONE);
            holder.llSex.setVisibility(View.VISIBLE);
        } else {
            holder.etName.setVisibility(View.VISIBLE);
            holder.llSex.setVisibility(View.GONE);
        }
        holder.etName.setHint("请输入新的" + name);
        holder.tvName.setText("原" + name + ": xxxxx");

    }


    static class ViewHolder {
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.et_name)
        EditText etName;
        @Bind(R.id.tv_title)
        TextView tvTitle;
        @Bind(R.id.rb1)
        RadioButton rb1;
        @Bind(R.id.rb2)
        RadioButton rb2;
        @Bind(R.id.rg)
        RadioGroup rg;
        @Bind(R.id.ll_sex)
        LinearLayout llSex;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
